namespace Scap.Data.Migrations
{
    using Scap.Info;
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;
    using WebMatrix.WebData;

    internal sealed class Configuration : DbMigrationsConfiguration<Scap.Data.ScapData>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(Scap.Data.ScapData context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            context.MonitorConfiguration.AddOrUpdate(
                new ScapMonitorConfiguration { 
                    Id=1, 
                    Interval=300 
                });

            context.EmailConfiguration.AddOrUpdate(
                new ScapEmailConfiguration { 
                    Id = 1,
                    Host = "smtp.gmail.com",
                    Port = 587,
                    Ssl = true,
                    Username = "scapsystem@gmail.com",
                    Password = "Asdfgh1234",
                    Email = "scapsystem@gmail.com"

                });


            context.DepartmentTypes.AddOrUpdate(
                new ScapDepartmentType { Id=1, Name = "Departamento" },
                new ScapDepartmentType { Id=2, Name = "Area" }
                );

            context.LocationCountries.AddOrUpdate(
                new ScapLocationCountry { Id = 1, Name = "Ecuador" }
                );

            context.LocationProvinces.AddOrUpdate(
                new ScapLocationProvince { Id = 1, Name = "Guayas", CountryId = 1 }
                );

            context.LocationCities.AddOrUpdate(
                new ScapLocationCity { Id = 1, Name = "Guayaquil", ProvinceId = 1 }
                );

            context.EmployeeTypes.AddOrUpdate(
                new ScapEmployeeType { Id = 1, Name = "Empleado" },
                new ScapEmployeeType { Id = 2, Name = "Contratista" }
                );

            context.EmployeeStatus.AddOrUpdate(
                new ScapEmployeeStatus { Id = 1, Name = "Permamente" },
                new ScapEmployeeStatus { Id = 2, Name = "Temporal" }
                );
            
            
            //WebSecurity.InitializeDatabaseConnection("SCAPDB", "UserProfile", "UserId", "UserName", autoCreateTables: true);

            //WebSecurity.CreateUserAndAccount("admin", "asdfgh");       
                
        }
    }
}
